{"ast":null,"code":"export var REQUIRED_FIELD='Обязательно для заполнения';var reg=/\\.[a-zа-я]{1,10}$/i;export var emailValidation={required:REQUIRED_FIELD,validate:function validate(value){if(value.length<4||value.length>128){return'Эл. адрес должен быть от 4 до 128 символов';}if(!reg.test(value)){return'Эл. адрес должен иметь тип: \"example@example.com\"';}return true;}};export var nicknameValidation={required:REQUIRED_FIELD,validate:function validate(value){if(value.length<2||value.length>30){return'Псевдоним должен быть от 2 до 30 символов';}return true;}};export var nicknameChangeValidation={validate:function validate(value){if(value){if(value.length!==0&&(value.length<2||value.length>30)){return'Псевдоним должен быть от 2 до 30 символов';}}return true;}};export var firstNameChangeValidation={validate:function validate(value){if(value){if(value.length!==0&&(value.length<2||value.length>30)){return'Имя должено быть от 2 до 30 символов';}}return true;}};export var lastNameChangeValidation={validate:function validate(value){if(value){if(value.length!==0&&(value.length<2||value.length>30)){return'Фамилия должена быть от 2 до 30 символов';}}return true;}};export var passwordValidation={required:REQUIRED_FIELD,validate:function validate(value){if(value.length<8){return'Пароль должен быть длиннее 8 символов';}return true;}};export var passwordChangeValidation={validate:function validate(value){if(value&&value.length<8){return'Пароль должен быть длиннее 8 символов';}return true;}};export var confirmPassword=function confirmPassword(firstValue,secondValue){return{required:REQUIRED_FIELD,validate:function validate(){if(firstValue!==secondValue){return'Пароли должны совпадать';}return true;}};};export var confirmChangePassword=function confirmChangePassword(firstValue,secondValue){if((firstValue===null||firstValue===void 0?void 0:firstValue.length)===0&&(secondValue===null||secondValue===void 0?void 0:secondValue.length)===0){return{required:false,validate:function validate(){return true;}};}if(firstValue!==null&&firstValue!==void 0&&firstValue.length||secondValue!==null&&secondValue!==void 0&&secondValue.length){if(firstValue!==null&&firstValue!==void 0&&firstValue.length&&secondValue!==null&&secondValue!==void 0&&secondValue.length){return{required:REQUIRED_FIELD,validate:function validate(){if(firstValue!==secondValue){return'Пароли должны совпадать';}return true;}};}else if(firstValue!==null&&firstValue!==void 0&&firstValue.length){return{required:REQUIRED_FIELD,validate:function validate(){return'Вы должны повторить пароль';}};}else if(secondValue!==null&&secondValue!==void 0&&secondValue.length){return{required:REQUIRED_FIELD,validate:function validate(){return'Вы сначала должны придумать пароль';}};}}else{return true;}};","map":{"version":3,"names":["REQUIRED_FIELD","reg","emailValidation","required","validate","value","length","test","nicknameValidation","nicknameChangeValidation","firstNameChangeValidation","lastNameChangeValidation","passwordValidation","passwordChangeValidation","confirmPassword","firstValue","secondValue","confirmChangePassword"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/modules/validation.ts"],"sourcesContent":["export const REQUIRED_FIELD = 'Обязательно для заполнения';\n\nconst reg = /\\.[a-zа-я]{1,10}$/i;\n\nexport const emailValidation = {\n    required: REQUIRED_FIELD,\n    validate: (value: string) => {\n        if (value.length < 4 || value.length > 128) {\n            return 'Эл. адрес должен быть от 4 до 128 символов'\n        }\n\n        if (!reg.test(value)) {\n            return 'Эл. адрес должен иметь тип: \"example@example.com\"'\n        }\n\n        return true;\n    }\n};\n\nexport const nicknameValidation = {\n    required: REQUIRED_FIELD,\n    validate: (value: string) => {\n        if (value.length < 2 || value.length > 30) {\n            return 'Псевдоним должен быть от 2 до 30 символов'\n        }\n\n        return true;\n    }\n};\n\nexport const nicknameChangeValidation = {\n    validate: (value: string | null | undefined) => {\n        if (value) {\n            if (value.length !== 0 && (value.length < 2 || value.length > 30)) {\n                return 'Псевдоним должен быть от 2 до 30 символов'\n            }\n        }\n\n        return true;\n    }\n};\n\nexport const firstNameChangeValidation = {\n    validate: (value: string | null | undefined) => {\n        if (value) {\n            if (value.length !== 0 && (value.length < 2 || value.length > 30)) {\n                return 'Имя должено быть от 2 до 30 символов'\n            }\n        }\n\n        return true;\n    }\n};\n\nexport const lastNameChangeValidation = {\n    validate: (value: string | null | undefined) => {\n        if (value) {\n            if (value.length !== 0 && (value.length < 2 || value.length > 30)) {\n                return 'Фамилия должена быть от 2 до 30 символов'\n            }\n        }\n\n        return true;\n    }\n};\n\nexport const passwordValidation = {\n    required: REQUIRED_FIELD,\n    validate: (value: string) => {\n        if (value.length < 8) {\n            return 'Пароль должен быть длиннее 8 символов'\n        }\n\n        return true;\n    }\n};\n\nexport const passwordChangeValidation = {\n    validate: (value: string | null | undefined) => {\n        if (value && value.length < 8) {\n            return 'Пароль должен быть длиннее 8 символов'\n        }\n\n        return true;\n    }\n};\n\nexport const confirmPassword = (firstValue: string, secondValue: string) => {\n    return {\n        required: REQUIRED_FIELD,\n        validate: () => {\n            if (firstValue !== secondValue) {\n                return 'Пароли должны совпадать';\n            }\n        return true;\n    }\n    }\n};\n\nexport const confirmChangePassword = (firstValue: string | null | undefined, secondValue: string | null | undefined) => {\n    if (firstValue?.length! === 0 && secondValue?.length! === 0) {\n        return {\n            required: false,\n            validate: () => true\n        };\n    }\n\n    if (firstValue?.length! || secondValue?.length!) {\n        if (firstValue?.length! && secondValue?.length!) {\n            return {\n                required: REQUIRED_FIELD,\n                validate: () => {\n                    if (firstValue !== secondValue) {\n                        return 'Пароли должны совпадать';\n                    }\n                    return true;\n                }\n            }\n        } else if (firstValue?.length!) {\n            return {\n                required: REQUIRED_FIELD,\n                validate: () => {\n                    return 'Вы должны повторить пароль';\n                }\n            }\n        } else if (secondValue?.length!) {\n            return {\n                required: REQUIRED_FIELD,\n                validate: () => {\n                    return 'Вы сначала должны придумать пароль';\n                }\n            }\n        }\n    }\n\n    else {\n        return true;\n    }\n};\n"],"mappings":"AAAA,MAAO,IAAMA,eAAc,CAAG,4BAA4B,CAE1D,GAAMC,IAAG,CAAG,oBAAoB,CAEhC,MAAO,IAAMC,gBAAe,CAAG,CAC3BC,QAAQ,CAAEH,cAAc,CACxBI,QAAQ,CAAE,kBAACC,KAAa,CAAK,CACzB,GAAIA,KAAK,CAACC,MAAM,CAAG,CAAC,EAAID,KAAK,CAACC,MAAM,CAAG,GAAG,CAAE,CACxC,MAAO,4CAA4C,CACvD,CAEA,GAAI,CAACL,GAAG,CAACM,IAAI,CAACF,KAAK,CAAC,CAAE,CAClB,MAA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